#pragma once
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include<WinSock2.h>
#include<iostream>
#pragma comment(lib,"ws2_32.lib")
using namespace std;

int UDP_server_main() {
	WSADATA data;
	WSAStartup(MAKEWORD(2, 2), &data);

	SOCKET fd1 = socket(AF_INET, SOCK_DGRAM, 0);
	sockaddr_in my_port = {};
	my_port.sin_family = AF_INET;
	my_port.sin_port = htons(80);
	my_port.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
	bind(fd1, (sockaddr*)&my_port, sizeof(my_port));

	char buff[100] = {};
	recvfrom(fd1, buff, 100, 0, 0, 0);
	cout << buff << endl;
	return 0;
}

int UDP_client_main() {
	WSADATA data;
	WSAStartup(MAKEWORD(2, 2), &data);

	SOCKET fd1 = socket(AF_INET, SOCK_DGRAM, 0);
	sockaddr_in server_port = {};
	server_port.sin_family = AF_INET;
	server_port.sin_port = htons(80);
	server_port.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");

	char buff[100] = {};
	cin >> buff;
	sendto(fd1, buff, 100, 0, (sockaddr*)&server_port, sizeof(server_port));
	return 0;
}